<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/12 0012
 * Time: 17:14
 */

namespace app\home\controller;


use app\model\model\Ad;
use app\model\model\Seo;
use app\model\model\Download_type;
use think\Request;

class Download extends Base
{
    protected $_Seo;
    protected $_Ad;
    protected $_Download;
    protected $_Download_type;
    public function __construct(Request $request = null){
        parent::__construct($request);

        $this->_Ad = new Ad();
        $this->_Seo = new Seo();
        $this->_Download = new \app\model\model\Download();
        $this->_Download_type = new Download_type();
    }
    public function index(){
        //SEO
        $seo = $this->_Seo->getOne(['id'=>1]);
        $this->assign('seo',$seo);
        //banner
        $banner = $this->_Ad->getListHome(['type_id'=>16,'flag'=>1]);
        $this->assign('banner',$banner);
        //列表
        $list = $this->_Download->getListSelect(['flag'=>1],true);
        foreach ($list as $v){
            $v['create_time'] = date('m, Y',$v['create_time']);
        }

        $this->assign('list',$list);
        $index = $this->_Download_type->getOne(11);
        $this->assign('index',$index);
        return $this->fetch();
    }
    public function getOne(){
        $data = $this->_Download->getOne(input('id'));
        $this->_Download->up(['id'=>$data['id']],['pv'=>($data['pv']+1),'downloads'=>($data['downloads']+1)]);

        return json_echo_msg(200,'1',$data);
    }
    public function downloadafter(){
        $this->assign('id',input('id'));
        return $this->fetch();
    }
    public function dow(){
        echo 'downloading';
    }
}